package top.codecrab.javase;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author codecrab
 * @since 2021年07月05日 12:50
 */
public class Server {
    public static void main(String[] args) {
        ServerSocket server;
        try {
            server = new ServerSocket(8001);
            Socket socket = server.accept();
            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            System.out.println(br.readLine());
            Writer writer = new OutputStreamWriter(socket.getOutputStream());
            writer.write("收到\n");
            writer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
